package com.kangye.enterprise.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kangye.enterprise.entity.*;
import com.kangye.enterprise.mapper.PlatformMapper;
import com.kangye.enterprise.service.PlatformService;
import com.kangye.enterprise.util.ViewJsonObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: enterprise
 * @description:
 * @author: 索腾龙
 * @create: 2021-06-08 13:34
 **/
@Service
@Transactional
public class PlatformServiceImpl implements PlatformService {
    @Autowired
    private PlatformMapper platformMapper;
    //平台统计查询
    @Override
    public ViewJsonObject<Platform> selPlatfrom(Platform platform) {
        //用list接收
        List<Platform> list = platformMapper.selPlatform(platform);
        return new ViewJsonObject<>(list);
    }
    //统计明细查询
    @Override
    public ViewJsonObject<Statistical> selStatistical(Integer page, Integer limit) {
        //把当前页和每页显示的条数传进来
        PageHelper.startPage(page, limit);
        //查询用户
        List<Statistical> list = platformMapper.selStatistical();
        //创建分页对象,把数据存在pageInfo里
        PageInfo<Statistical> pageInfo = new PageInfo<Statistical>(list);
        //返回json页面
        return new ViewJsonObject<Statistical>(pageInfo.getList(), pageInfo.getTotal());
    }
    //查询领域名字
    @Override
    public ViewJsonObject<Domoin> selDomoin() {
        List<Domoin> list = platformMapper.selDomoin();
        return new ViewJsonObject<Domoin>(list);
    }
    //查询政策名字
    @Override
    public ViewJsonObject<Circular> selCirculars() {
        List<Circular> list = platformMapper.selCirculars();
        return new ViewJsonObject<Circular>(list);
    }
    //查询项目名字
    @Override
    public ViewJsonObject<Item> selItemAll() {
        List<Item> list = platformMapper.selItemAll();
        return new ViewJsonObject<Item>(list);
    }
}